package org.lem

import grails.test.*

class VolunteerDaysTimeTests extends GrailsUnitTestCase {
    protected void setUp() {
        super.setUp()
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testGetVolunteer()
    {
      def volunteer = new Volunteer(volunteerId:1,
        applicationDate:null,
        firstName:"firstName",
        middleName:null,
        lastName:"lastName",
        homeAddress:null,
        city:null,
        state:null,
        zip:null,
        homePhone:null,
        cellPhone:null,
        workPhone:null,
        workExt:null,
        emailAddress:"test@test.com",
        secondaryEmailAddress:null,
        gender:null,
        dateOfBirth:null,
        countryOfBirth:null,
        nativeLanguage:null,
        otherLanguages:null,
        ethnicity:null,
        occupation:null,
        employerMatchingGifts:null,
        teachingLocation:null,
        teachingTime:null,
        teachingDay:null,
        teachingPosition:null,
        teachingLevel:null,
        affiliations:null,
        nonCatholicAffiliation:null,
        status:null,
        comments:null,
        preferredPosition:null,
        orientationDate:null,
        trainingDate:null,
        inputBy:null,
        inputDate:null)
      mockDomain(Volunteer, [volunteer])
      
      Volunteer result = Volunteer.findByVolunteerId(Long.valueOf("1"))
      assertNotNull result
      result = Volunteer.findByFirstNameAndLastName("firstName","lastName")
      assertTrue result.id == 1
    }

    void testInsert() {
      def volunteer = new Volunteer(id:1,
        firstName:"firstName",
        lastName:"lastName")
      mockDomain(Volunteer,[volunteer])
      
      def classDay = new ClassDay(name:"classDay")
      mockDomain(ClassDay,[classDay])
      
      def classTime = new ClassTime(time:"classTime")
      mockDomain(ClassTime,[classTime])
      
      VolunteerDaysTime volunteerDaysTime = new VolunteerDaysTime(id:1,
        volunteer:Volunteer.findByVolunteerId((Long)1),
        inputBy:Volunteer.findByFirstNameAndLastName("firstName", "lastName"),
        inputDate:new Date(),
        preferredDay:ClassDay.findByName("classDay"),
        preferredTime:ClassTime.findByTime("classTime")
      )
      
      volunteerDaysTime.save()
      if(volunteerDaysTime.hasErrors())
      {
        println volunteerDaysTime.errors 
      }
      result = VolunteerDaysTime.findById(1)
      assertNotNull result
    }
}
